import React, { Component } from 'react'
import Child1 from '../components/Child1'

export default class PTC extends Component {
    constructor(){
        super();
        this.state = {
            num:10
        }
    }
    updateNum = (n)=>{
        this.setState({//调用了setState  render会重学的渲染
            num:this.state.num+n
        })
    }
  render() {
    return (
      <div>
        <h2>父传子 父元素的数据为{this.state.num}</h2>
        <Child1 num={this.state.num} age={18} onChangeNum={this.updateNum}></Child1>
      </div>
    )
  }
}
